package com.heima.common.util;

import com.heima.common.dto.User;

public class ArticleThreadLocalUtil {

    private static ThreadLocal<User> threadLocal = new ThreadLocal<User>();

    /**
     * 设置本地线程
     * @param user
     */
    public static void set(User user){
        threadLocal.set(user);
    }

    /**
     * 获取本地线程中的用户信息
     * @return
     */
    public static User get(){
        return threadLocal.get();
    }

    /**
     * 释放用户 --- 防止内存泄露
     */
    public static void remove(){
        threadLocal.remove();
    }
}
